<?php
include ('../parametros/bd.php');
//include ('encabezado.php');
$conect = new conector_pg();
$conect-> conectar();

if($_SERVER["REQUEST_METHOD"] == "POST"){
	if (isset($_POST["guardar"])){

		$upd="insert into authentication(username,
										direccion,
										email,
										nombre,
										apellido,
										admin,
										estado)
								values('".$_POST['username']."',
									     '".$_POST['direccion']."',
									     '".$_POST['email']."',
									     '".$_POST['nombre']."',
									     '".$_POST['apellido']."',
									     '".$_POST['admin']."',
									     '".$_POST['estado']."')";
		
		$result = $conect->consultar($upd);
			if (!$result)
		 	{
				echo 'error en la consulta'	;
				exit;
		 	}else{
		 		header("Location: verusuarios.php");
		 	}		
	}
}
?>
<?php if (isset($_SESSION['logged_in'])) 
	   { 
	   	if ($_SESSION['admin'] == 1)
	   	{ 
?>
<html>
<head>
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" />
<link href="../css/imageMenu.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="XoR-main">
			<div class="XoR-sheet">
				<div class="XoR-sheet-tl"></div>
				<div class="XoR-sheet-tr"></div>
				<div class="XoR-sheet-bl"></div>
				<div class="XoR-sheet-br"></div>
				<div class="XoR-sheet-tc"></div>
				<div class="XoR-sheet-bc"></div>
				<div class="XoR-sheet-cl"></div>
				<div class="XoR-sheet-cr"></div>
				<div class="XoR-sheet-cc"></div>
				<div class="XoR-sheet-body">
					<div class="XoR-header">
						<div class="XoR-header-center">
							<div class="XoR-header-png"></div>
							<div class="XoR-header-jpeg"></div>
						</div>
						<div class="XoR-logo">
							<h1 id="name-text" class="XoR-logo-name"><a href="./index.html">Libreria TAI</a></h1>
							<h2 id="slogan-text" class="XoR-logo-text">Primera Libreria Online del Paraguay</h2>
						</div>
					</div>				
					
<h1 id="tituloNaranja2">Insertar nuevo usuario</h1>
<form name="nvousuario" action="nuevousuario.php" method="post">
    <table>
    	<tr>
            <td id="labelLogin">
                Username:&nbsp;
            </td> 
            <td>
                <input type="text" name="username" value="" id="searchForm"/>
            </td>
        </tr>
        <tr>
            <td id="labelLogin">
                Nombre:&nbsp;
            </td>
            <td>
                <input type="text" name="nombre" value="" id="searchForm"/>
            </td>
        </tr>
        <tr>
            <td id="labelLogin">
                Apellido:&nbsp;
            </td>
            <td>
                <input type="text" name="apellido" value="" id="searchForm"/>
            </td>
        </tr>
         <tr>
            <td id="labelLogin">
                Email:&nbsp;
            </td>
            <td>
                <input type="text" name="email" value="" id="searchForm"/>
            </td>
        </tr>
        <tr>
            <td id="labelLogin">
                Direccion:&nbsp;
            </td> 
            <td>
                <input type="text" name="direccion" value="" id="searchForm"/>
            </td>
        </tr>         
        <tr>
        	<td id="labelLogin">
               Permisos:&nbsp;
        	</td> 
        	<td><select name="admin" id="searchForm">	
			<option value="1">Administrador</option>
			<option value="0">Usuario</option>
			</select></td>
        </tr>
        <tr>
        <td id="labelLogin">
               Estado:&nbsp;
        </td> 
        <td><select name="estado" id="searchForm">	
			<option value="1">Activo</option>
			<option value="0">Inactivo</option>
			</select></td>
        </tr>
        <tr>
            <td id="labelLogin" colspan="2">
                <input type="submit" name="guardar" value="Guardar" id="submitLogin"/>
                <a href="indexadmin.php"> Regrese al listado </a>
            </td>
        </tr>

    </table>
</form>
<?php 
	   	}
?>
<a href="../login/logout.php?signature=<?php echo $_SESSION['signature']; ?>
">Logout</a><br /><?php } 
?>
<div class="cleared"></div>
					<div class="XoR-footer">
						<div class="XoR-footer-body">
							<div class="XoR-footer-text">
								<p>Copyright 2011, XoR Company. All Rights Reserved.</p>
							</div>
							<div class="cleared"></div>
						</div>
					</div>
					<div class="cleared"></div>
				</div>
			</div>
			<div class="cleared"></div>
			<p class="XoR-page-footer">Powered by <a href="http://xor.net/">XoR.org</a> </p>
</div>
</body>
</html>